package com.ftu.study.pattern.observer.impl;

import com.ftu.study.pattern.observer.DisplayElement;
import com.ftu.study.pattern.observer.Observer;
import com.ftu.study.pattern.observer.Subject;

public class CurrentConditionsDisplay implements Observer, DisplayElement {
    private float temperature;
    private float humidity;
    private Subject weatherData;
    
    public CurrentConditionsDisplay(Subject weatherData) {
        this.weatherData = weatherData;
        weatherData.registerObserver(this);
    }
    
    @Override
    public void display() {
        System.out.println("Current conditions: "+ temperature +" F degrees and "
                + humidity +" % humidity.");
    }

    @Override
    public void update(float temperature, float humidity, float pressure) {
        this.humidity = humidity;
        this.temperature = temperature;
        display();
    }

}
